<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="${pageContext.request.contextPath}/js/jquery-1.11.3.js"></script>

    <title>登录界面</title>
    <script type="text/javascript" src="/sshkaoshi/js/jquery-1.2.6.min.js"></script>
    <script type="text/javascript" src="/sshkaoshi/js/Login.js"></script>
</head>
<body>

<h3><font color="red">${msg }</font></h3>
<b>查询</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b id="error"></b><br/>
<form action="${pageContext.request.contextPath}/login.action" method="post">
    <table border="1px" width="50%">
        <tr>
            <td>用户名</td>
            <td><input type="text" name="username" id="username"/></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" name="password" id="password"/></td>
        </tr>

    </table>
    <input type="submit" name="login" value="登录"/>
</form>
<a onclick="login()" href="#">Login</a>
<script type="text/javascript">



    function login() {
        $.post("${pageContext.request.contextPath}/login.action", {
            "username": $("#username").val(),
            "password": $("#password").val()
        }, function (data) {
            if (data == 0) {
                $("#error").html("用户名或密码错误");
            } else {
                window.location.href = "${pageContext.request.contextPath}/list.jsp"
            }
        }, "json");
    }
</script>
</body>

</html>















